﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Threading;


namespace DaZhong
{
    public class BaseForm : Form
    {
        

        protected TextBox textBox = null;

        /// <summary>
        /// 定义显示消息委托
        /// </summary>
        /// <param name="msg"></param>
        public delegate void MyShowMessage(string msg,bool replace=false);




        protected string FillterLink(string html)
        {
            return html;
        }

        protected void Echo(object msg,bool replace=false)
        {
            if (textBox == null) return;

            if (textBox.InvokeRequired)
            {
                MyShowMessage _myInvoke = new MyShowMessage(Echo);
                textBox.Invoke(_myInvoke, new object[] { msg,replace });
            }
            else
            {
                //if (textBox.Text.Length > 2000)
                //    textBox.Text = textBox.Text.Substring(1000);
                if (!replace)
                {
                    textBox.AppendText(Environment.NewLine + msg);
                }
                else
                    textBox.AppendText(Environment.NewLine + msg);
                textBox.ScrollToCaret();
            }

        }
        protected void Sleep()
        {
            Thread.CurrentThread.Abort();
        }
    }
}